package com.example.demo;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/*
* HTTP 请求和HTTP响应消息的格式类似
*
* */

/*
* Servlet
*
* 设置任意状态码
* setStatus
* 生成302响应，连同一个带有新文档URL的Location头
* sendRedirect
* 该方法发送一个状态码 通常404  连同一个在HTML文档内部自动格式化并发送到客户端的短消息
* sendError
*
* */

@WebServlet("/showError")
public class ShowError extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        resp.setStatus(500);
        resp.sendError(501,"error");
    }


    public void destroy() {

    }
}
